﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using System.Diagnostics;

namespace EagleJournal
{
    class Class1
    {
        public void inserttoClient(String name, int contactnum)
        {
            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "INSERT INTO client (clientname, contactInfo) VALUES('" + name + "', '" + contactnum + "')";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand(query, myConnection);
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }
        public void inserttoPO(int POserial, String ClientName, DateTime dateIssued, float amount, String company, String desc, int clientID)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "INSERT INTO purchaseorder (purchaseorderSerial,clientName,dateIssued,amount,company,description,clientID) VALUES('" + POserial + "','" + ClientName + "','" + dateIssued + "','" + amount + "','" + company + "','" + desc + "','" + clientID + "')";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand(query, myConnection);
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }

        public void inserttoDeadline(int clientid, int POid, DateTime deadline)
        {

            try
            {
                MySqlConnection myConnection;
                string server;
                string database;
                string uid;
                string password;
                //MySqlDataReader dataReader;
                string query = "INSERT INTO deadline (clientid, purchaseOrderid,deadline) VALUES('" + clientid + "', '" + POid + ",'" + deadline + "')";
                server = "localhost";
                database = "travel_cmp_db";
                uid = "root";
                password = "p@ssword";
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "DATABASE=" +
                database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";

                myConnection = new MySqlConnection(connectionString);
                myConnection.Open();
                MySqlCommand cmd = new MySqlCommand(query, myConnection);
                cmd.ExecuteNonQuery();
                myConnection.Close();

            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
        }

    }
}
